<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id='test1'></div>
   

    <script src="../demo1/js/react.development.js"></script>
     <script src="../demo1/js/react-dom.development.js"></script>
     <script src="../demo1/js/babel.min.js"></script>
     <script src="./js/prop-types.js"></script> 
     <!-- 全局有了 PropTypes -->
     <script type="text/babel">
       class Demo extends React.Component{
        /*
            createRef 可返回一个容器  可以存放被标识的节点
        */

        myRef1 = React.createRef() // 专人专用
        myRef2 = React.createRef()

        showData1 = ()=>{
            // 是myRef.current
           alert(this.myRef1.current.value)
        }

        showData2 = ()=>{
            alert(this.myRef2.current.value)
        }

           
        render() {
            return (
                //  createRef 创建 ref
                <div>
                    <input ref={this.myRef1} type="text"/>
                    <button  onClick={this.showData1} >点我，显示内容</button>    
                    <input ref={this.myRef2} onBlur={this.showData2}  type="text"/>
                </div>
            )   
        }
       }

       ReactDOM.render(<Demo/>,document.querySelector('#test1'))

     </script>
</body>
</html>